package com.ellricky.baselib.adapter.visit

import android.content.Intent
import android.widget.TextView
import com.andr.common.ui.adapter.BaseRecyclerAdapter
import com.andr.common.ui.adapter.SmartViewHolder
import com.ellricky.baselib.BaseConstant
import com.ellricky.baselib.R
import com.ellricky.baselib.entity.new.ReturnCallback
import com.ellricky.baselib.ui.FillVisitRecordActivity
import com.ellricky.baselib.ui.TrackActivity
import com.ellricky.baselib.ui.clue.VisitDetailActivity
import com.ellricky.baselib.util.jump

class VisitAdapter2(val returnNum: String) :
    BaseRecyclerAdapter<ReturnCallback>(R.layout.base_adapter_visit_2) {

    override fun onBindViewHolder(vh: SmartViewHolder, data: ReturnCallback, p2: Int) {
        vh.text(R.id.tv_name, data.member_name)
            .text(R.id.tv_return_name, data.return_name)
        if (returnNum == "0") {
            vh.text(R.id.tv_visit_add, "添加回访记录")
            vh.itemView.findViewById<TextView>(R.id.tv_visit_add).setOnClickListener {
                it.context.startActivity(
                    Intent(
                        it.context,
                        FillVisitRecordActivity::class.java
                    ).apply {
                        putExtra(BaseConstant.KEY_ID, data.member_return_id)
                    }
                )
            }
        } else {
            vh.text(R.id.tv_visit_add, "查看回访记录")
            vh.itemView.findViewById<TextView>(R.id.tv_visit_add).setOnClickListener {
                it.context.startActivity(
                    Intent(
                        it.context,
                        VisitDetailActivity::class.java
                    ).apply {
                        putExtra(BaseConstant.KEY_ID, data.member_return_id)
                    }
                )
            }
        }
    }
}